package jvm;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Singleton {

	private static Singleton singleton;

	private Singleton() {
	}

	public static Singleton getInstance() {
		if (singleton == null) {
			singleton = new Singleton();
		}
		return singleton;
	}
	
	public static void main(String[] args) {
		Callable<Singleton> thread = new MyThread();
		FutureTask<Singleton> task = new FutureTask<Singleton>(thread);
		
	
			try {
				Singleton singleton = task.get();
				System.out.println(singleton);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ExecutionException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}

}

class MyThread implements Callable<Singleton> {

	@Override
	public Singleton call() throws Exception {

		return Singleton.getInstance();
	}

}